package com.ad.pet.app.main.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.view.ViewGroup;

import java.util.List;

/**
 * Created by SEELE on 2018/12/20.
 */

public class HomeViewPagerAdapter extends FragmentStatePagerAdapter{
    private List<Fragment> mList;
    private List<String> mLabels;

    public HomeViewPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    public void setData(List<Fragment> list,List<String> labels) {
        mList = list;
        mLabels = labels;
    }


    @Override
    public Fragment getItem(int position) {
        return mList.get(position);
    }

    @Override
    public int getCount() {
        return mLabels==null?0:mLabels.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return  mLabels.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
//        super.destroyItem(container, position, object);
    }

}